<?php

/*周公解梦*/

class Dream
{
    public static function getDream($keywords)
    {
        $url = 'http://v.juhe.cn/dream/query';
        $key = 'dbd8a10f3053217aaea1b784439f7272';
        $curl = new Curl\Curl();
        $getData = $curl->get($url, array(
            'key' => $key,
            'q' => $keywords,
            'full'=>1
        ));

        $data = json_decode($getData->response, true);
        $res = "{$keywords}:
";
        if($data['reason'] == 'successed' && !empty($result = $data['result'])){
            $res .= implode( '
            
', current($result)['list']);
        }else{
            $res .= '没有数据';
        }
        return $res;
    }
}